#ifndef MAINWINDOW_H
#define MAINWINDOW_H

#include "primitiveploy.h"
#include <QButtonGroup>
#include <QMainWindow>
#include <QPushButton>
#include <QVector>
#include <bitset>

QT_BEGIN_NAMESPACE
namespace Ui {
class MainWindow;
}
QT_END_NAMESPACE

class LFSR {
public:
  std::bitset<64> polynomial_coefficients, init_value, bitin, bitout;
  PrimitivePloy poly;
  int cnt = 0;
  QButtonGroup *pbtn_Group;
  QPushButton **pbtn_Bit;
  LFSR(unsigned long long coef = 0x10039, unsigned long long value = 0xFFFF);
  unsigned int getNext();
  unsigned int getNextbit();
  //  unsigned int getNextbit_8();
  //  unsigned int getNextbit_16();
  //  unsigned int getNextbit_23();
  //  unsigned int getNext16bit();
};

class MainWindow : public QMainWindow {
  Q_OBJECT

public:
  MainWindow(QWidget *parent = nullptr);
  ~MainWindow();
public slots:
  void updateScramble();

private slots:
  void on_btn_next_clicked();
  //  void on_le_input_textEdited(const QString &arg);
  void on_le_input_textChanged(const QString &arg1);
  void on_btn_run_clicked();
  void on_le_polynomial_textChanged(const QString &arg1);

private:
  bool inputchanged;
  Ui::MainWindow *ui;
  LFSR reg;
};
#endif // MAINWINDOW_H
